<?php

namespace App\Http\Controllers\Backend;

use App\Http\Resources\Backend\FoodTypeResource;
use App\Models\FoodType;
use Illuminate\Http\Request;

/**
 * Class FoodTypeController
 * @package App\Http\Controllers\Backend
 * 菜品种类
 */
class FoodTypeController extends BackendController
{
    /**
     * @param Request $request
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     * 菜品种类列表
     */
    public function index(Request $request)
    {
        $foodTypes = FoodType::orderBy('sort', 'asc')->with('school')
            ->nameLike($request->name)
            ->schoolIs($request->school_id)
            ->statusIs($request->status)
            ->paginate($request->size);
        return FoodTypeResource::collection($foodTypes);
    }
}